<!DOCTYPE html>
<html lang="en" dir="ltr" class="client-nojs">
<head>
<title>std::ranges::views::as_const, std::ranges::as_const_view - cppreference.com</title>
<meta charset="UTF-8">
<meta name="generator" content="MediaWiki 1.21.2">
<link rel="shortcut icon" href="../../../common/favicon.ico">
<link rel="stylesheet" href="../../../common/ext.css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" href="../../../common/site_modules.css">
<style>a:lang(ar),a:lang(ckb),a:lang(fa),a:lang(kk-arab),a:lang(mzn),a:lang(ps),a:lang(ur){text-decoration:none}#toc{display:none}.editsection{display:none}
/* cache key: mwiki1-mwiki_en_:resourceloader:filter:minify-css:7:472787eddcf4605d11de8c7ef047234f */</style>

<script src="../../../common/startup_scripts.js"></script>
<script>if(window.mw){
mw.config.set({"wgCanonicalNamespace":"","wgCanonicalSpecialPageName":false,"wgNamespaceNumber":0,"wgPageName":"cpp/ranges/as_const_view","wgTitle":"cpp/ranges/as const view","wgCurRevisionId":141609,"wgArticleId":21030,"wgIsArticle":true,"wgAction":"view","wgUserName":null,"wgUserGroups":["*"],"wgCategories":["Todo with reason"],"wgBreakFrames":false,"wgPageContentLanguage":"en","wgSeparatorTransformTable":["",""],"wgDigitTransformTable":["",""],"wgDefaultDateFormat":"dmy","wgMonthNames":["","January","February","March","April","May","June","July","August","September","October","November","December"],"wgMonthNamesShort":["","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],"wgRelevantPageName":"cpp/ranges/as_const_view","wgRestrictionEdit":[],"wgRestrictionMove":[]});
}</script><script>if(window.mw){
mw.loader.implement("user.options",function(){mw.user.options.set({"ccmeonemails":0,"cols":80,"date":"default","diffonly":0,"disablemail":0,"disablesuggest":0,"editfont":"default","editondblclick":0,"editsection":0,"editsectiononrightclick":0,"enotifminoredits":0,"enotifrevealaddr":0,"enotifusertalkpages":1,"enotifwatchlistpages":0,"extendwatchlist":0,"externaldiff":0,"externaleditor":0,"fancysig":0,"forceeditsummary":0,"gender":"unknown","hideminor":0,"hidepatrolled":0,"imagesize":2,"justify":0,"math":1,"minordefault":0,"newpageshidepatrolled":0,"nocache":0,"noconvertlink":0,"norollbackdiff":0,"numberheadings":0,"previewonfirst":0,"previewontop":1,"quickbar":5,"rcdays":7,"rclimit":50,"rememberpassword":0,"rows":25,"searchlimit":20,"showhiddencats":0,"showjumplinks":1,"shownumberswatching":1,"showtoc":0,"showtoolbar":1,"skin":"cppreference2","stubthreshold":0,"thumbsize":2,"underline":2,"uselivepreview":0,"usenewrc":0,"watchcreations":0,"watchdefault":0,"watchdeletion":0,
"watchlistdays":3,"watchlisthideanons":0,"watchlisthidebots":0,"watchlisthideliu":0,"watchlisthideminor":0,"watchlisthideown":0,"watchlisthidepatrolled":0,"watchmoves":0,"wllimit":250,"variant":"en","language":"en","searchNs0":true,"searchNs1":false,"searchNs2":false,"searchNs3":false,"searchNs4":false,"searchNs5":false,"searchNs6":false,"searchNs7":false,"searchNs8":false,"searchNs9":false,"searchNs10":false,"searchNs11":false,"searchNs12":false,"searchNs13":false,"searchNs14":false,"searchNs15":false,"gadget-ColiruCompiler":1,"gadget-MathJax":1});;},{},{});mw.loader.implement("user.tokens",function(){mw.user.tokens.set({"editToken":"+\\","patrolToken":false,"watchToken":false});;},{},{});
/* cache key: mwiki1-mwiki_en_:resourceloader:filter:minify-js:7:9f05c6caceb9bb1a482b6cebd4c5a330 */
}</script>
<script>if(window.mw){
mw.loader.load(["mediawiki.page.startup","mediawiki.legacy.wikibits","mediawiki.legacy.ajax"]);
}</script>
<style type="text/css">/*<![CDATA[*/
.source-cpp {line-height: normal;}
.source-cpp li, .source-cpp pre {
	line-height: normal; border: 0px none white;
}
/**
 * GeSHi Dynamically Generated Stylesheet
 * --------------------------------------
 * Dynamically generated stylesheet for cpp
 * CSS class: source-cpp, CSS id: 
 * GeSHi (C) 2004 - 2007 Nigel McNie, 2007 - 2008 Benny Baumann
 * (http://qbnz.com/highlighter/ and http://geshi.org/)
 * --------------------------------------
 */
.cpp.source-cpp .de1, .cpp.source-cpp .de2 {font: normal normal 1em/1.2em monospace; margin:0; padding:0; background:none; vertical-align:top;}
.cpp.source-cpp  {font-family:monospace;}
.cpp.source-cpp .imp {font-weight: bold; color: red;}
.cpp.source-cpp li, .cpp.source-cpp .li1 {font-weight: normal; vertical-align:top;}
.cpp.source-cpp .ln {width:1px;text-align:right;margin:0;padding:0 2px;vertical-align:top;}
.cpp.source-cpp .li2 {font-weight: bold; vertical-align:top;}
.cpp.source-cpp .kw1 {color: #0000dd;}
.cpp.source-cpp .kw2 {color: #0000ff;}
.cpp.source-cpp .kw3 {color: #0000dd;}
.cpp.source-cpp .kw4 {color: #0000ff;}
.cpp.source-cpp .co1 {color: #909090;}
.cpp.source-cpp .co2 {color: #339900;}
.cpp.source-cpp .coMULTI {color: #ff0000; font-style: italic;}
.cpp.source-cpp .es0 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es1 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es2 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es3 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es4 {color: #008000; font-weight: bold;}
.cpp.source-cpp .es5 {color: #008000; font-weight: bold;}
.cpp.source-cpp .br0 {color: #008000;}
.cpp.source-cpp .sy0 {color: #008000;}
.cpp.source-cpp .sy1 {color: #000080;}
.cpp.source-cpp .sy2 {color: #000040;}
.cpp.source-cpp .sy3 {color: #000040;}
.cpp.source-cpp .sy4 {color: #008080;}
.cpp.source-cpp .st0 {color: #008000;}
.cpp.source-cpp .nu0 {color: #000080;}
.cpp.source-cpp .nu6 {color: #000080;}
.cpp.source-cpp .nu8 {color: #000080;}
.cpp.source-cpp .nu12 {color: #000080;}
.cpp.source-cpp .nu16 {color:#000080;}
.cpp.source-cpp .nu17 {color:#000080;}
.cpp.source-cpp .nu18 {color:#000080;}
.cpp.source-cpp .nu19 {color:#000080;}
.cpp.source-cpp .ln-xtra, .cpp.source-cpp li.ln-xtra, .cpp.source-cpp div.ln-xtra {background-color: #ffc;}
.cpp.source-cpp span.xtra { display:block; }

/*]]>*/
</style><!--[if lt IE 7]><style type="text/css">body{behavior:url("/mwiki/skins/cppreference2/csshover.min.htc")}</style><![endif]--></head>
<body class="mediawiki ltr sitedir-ltr ns-0 ns-subject page-cpp_ranges_as_const_view skin-cppreference2 action-view cpp-navbar">
        <!-- header -->
        <!-- /header -->
        <!-- content -->
<div id="cpp-content-base">
            <div id="content">
                <a id="top"></a>
                <div id="mw-js-message" style="display:none;"></div>
                                <!-- firstHeading -->
<h1 id="firstHeading" class="firstHeading"><span style="font-size:0.7em; line-height:130%">std::ranges::</span><span style="font-size:0.7em; line-height:130%">views::</span>as_const, <span style="font-size:0.7em; line-height:130%">std::ranges::</span>as_const_view</h1>
                <!-- /firstHeading -->
                <!-- bodyContent -->
                <div id="bodyContent">
                                        <!-- tagline -->
                    <div id="siteSub">From cppreference.com</div>
                    <!-- /tagline -->
                                        <!-- subtitle -->
                    <div id="contentSub"><span class="subpages">&lt; <a href="../../cpp.html" title="cpp">cpp</a>‎ | <a href="../ranges.html" title="cpp/ranges">ranges</a></span></div>
                    <!-- /subtitle -->
                                                            <!-- bodycontent -->
                    <div id="mw-content-text" lang="en" dir="ltr" class="mw-content-ltr"><div class="t-navbar" style=""><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../../cpp.html" title="cpp"> C++</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="line-height:1.1em;">
<tr class="t-nv"><td colspan="5"> <a href="../compiler_support.html" title="cpp/compiler support"> Compiler support</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../freestanding.html" title="cpp/freestanding"> Freestanding and hosted</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../language.html" title="cpp/language"> Language</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../header.html" title="cpp/header"> Standard library headers</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../named_req.html" title="cpp/named req"> Named requirements </a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../feature_test.html" title="cpp/feature test"> Feature test macros </a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../utility.html#Language_support" title="cpp/utility"> Language support library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../concepts.html" title="cpp/concepts"> Concepts library</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../meta.html" title="cpp/meta"> Metaprogramming library</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../error.html" title="cpp/error"> Diagnostics library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../utility.html" title="cpp/utility"> General utilities library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../string.html" title="cpp/string"> Strings library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../container.html" title="cpp/container"> Containers library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../iterator.html" title="cpp/iterator"> Iterators library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../ranges.html" title="cpp/ranges"> Ranges library</a> <span class="t-mark-rev t-since-cxx20">(C++20)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../algorithm.html" title="cpp/algorithm"> Algorithms library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../numeric.html" title="cpp/numeric"> Numerics library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../locale.html" title="cpp/locale"> Localizations library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../io.html" title="cpp/io"> Input/output library</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../filesystem.html" title="cpp/filesystem"> Filesystem library</a> <span class="t-mark-rev t-since-cxx17">(C++17)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../regex.html" title="cpp/regex"> Regular expressions library</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../thread.html" title="cpp/thread"> Concurrency support library</a> <span class="t-mark-rev t-since-cxx11">(C++11)</span> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../experimental.html" title="cpp/experimental"> Technical specifications</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../symbol_index.html" title="cpp/symbol index"> Symbols index</a> </td></tr>
<tr class="t-nv"><td colspan="5"> <a href="../links/libs.html" title="cpp/links/libs"> External libraries</a> </td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div><div class="t-navbar-head"><a href="../ranges.html" title="cpp/ranges"> Ranges library</a><div class="t-navbar-menu"><div><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv-h2"><td colspan="5"> <a href="../ranges.html#Range_access" title="cpp/ranges">Range access</a></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="begin.html" title="cpp/ranges/begin"><span class="t-lines"><span>begin</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="cbegin.html" title="cpp/ranges/cbegin"><span class="t-lines"><span>cbegin</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="end.html" title="cpp/ranges/end"><span class="t-lines"><span>end</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="cend.html" title="cpp/ranges/cend"><span class="t-lines"><span>cend</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="rbegin.html" title="cpp/ranges/rbegin"><span class="t-lines"><span>rbegin</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="crbegin.html" title="cpp/ranges/crbegin"><span class="t-lines"><span>crbegin</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="rend.html" title="cpp/ranges/rend"><span class="t-lines"><span>rend</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="crend.html" title="cpp/ranges/crend"><span class="t-lines"><span>crend</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="size.html" title="cpp/ranges/size"><span class="t-lines"><span>size</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ssize.html" title="cpp/ranges/ssize"><span class="t-lines"><span>ssize</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="data.html" title="cpp/ranges/data"><span class="t-lines"><span>data</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="cdata.html" title="cpp/ranges/cdata"><span class="t-lines"><span>cdata</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="empty.html" title="cpp/ranges/empty"><span class="t-lines"><span>empty</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="../ranges.html#Range_conversions" title="cpp/ranges">Range conversions</a></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="to.html" title="cpp/ranges/to"><span class="t-lines"><span>to</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="../ranges.html#Range_primitives" title="cpp/ranges">Range primitives</a></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="iterator_t.html" title="cpp/ranges/iterator t"><span class="t-lines"><span>range_size_t</span><span>range_difference_t</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="iterator_t.html" title="cpp/ranges/iterator t"><span class="t-lines"><span>range_value_t</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="iterator_t.html" title="cpp/ranges/iterator t"><span class="t-lines"><span>range_reference_t</span><span>range_const_reference_t</span><span>range_rvalue_reference_t</span></span></a></div><div><span class="t-lines"><span>  </span><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="iterator_t.html" title="cpp/ranges/iterator t"><span class="t-lines"><span>iterator_t</span><span>const_iterator_t</span><span>sentinel_t</span></span></a></div><div><span class="t-lines"><span></span><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="../ranges.html#Dangling_iterator_handling" title="cpp/ranges">Dangling iterator handling</a></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="dangling.html" title="cpp/ranges/dangling"><span class="t-lines"><span>dangling</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="borrowed_iterator_t.html" title="cpp/ranges/borrowed iterator t"><span class="t-lines"><span>borrowed_iterator_t</span></span></a></div><div><span class="t-lines"><span>  </span></span></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="borrowed_iterator_t.html" title="cpp/ranges/borrowed iterator t"><span class="t-lines"><span>borrowed_subrange_t</span></span></a></div><div><span class="t-lines"><span>  </span></span></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="../ranges.html#Range_concepts" title="cpp/ranges">Range concepts</a></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="range.html" title="cpp/ranges/range"><span class="t-lines"><span>range</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="borrowed_range.html" title="cpp/ranges/borrowed range"><span class="t-lines"><span>borrowed_range</span></span></a></div><div><span class="t-lines"><span>  </span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="sized_range.html" title="cpp/ranges/sized range"><span class="t-lines"><span>sized_range</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="constant_range.html" title="cpp/ranges/constant range"><span class="t-lines"><span>constant_range</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="common_range.html" title="cpp/ranges/common range"><span class="t-lines"><span>common_range</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="view.html" title="cpp/ranges/view"><span class="t-lines"><span>view</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="viewable_range.html" title="cpp/ranges/viewable range"><span class="t-lines"><span>viewable_range</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="input_range.html" title="cpp/ranges/input range"><span class="t-lines"><span>input_range</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="output_range.html" title="cpp/ranges/output range"><span class="t-lines"><span>output_range</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="forward_range.html" title="cpp/ranges/forward range"><span class="t-lines"><span>forward_range</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="bidirectional_range.html" title="cpp/ranges/bidirectional range"><span class="t-lines"><span>bidirectional_range</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="random_access_range.html" title="cpp/ranges/random access range"><span class="t-lines"><span>random_access_range</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="contiguous_range.html" title="cpp/ranges/contiguous range"><span class="t-lines"><span>contiguous_range</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="../ranges.html#Views" title="cpp/ranges">Views</a></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="view_interface.html" title="cpp/ranges/view interface"><span class="t-lines"><span>view_interface</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="subrange.html" title="cpp/ranges/subrange"><span class="t-lines"><span>subrange</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="../ranges.html#Range_factories" title="cpp/ranges">Factories</a></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="empty_view.html" title="cpp/ranges/empty view"><span class="t-lines"><span>empty_view</span><span>views::empty</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="iota_view.html" title="cpp/ranges/iota view"><span class="t-lines"><span>iota_view</span><span>views::iota</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="single_view.html" title="cpp/ranges/single view"><span class="t-lines"><span>single_view</span><span>views::single</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="basic_istream_view.html" title="cpp/ranges/basic istream view"><span class="t-lines"><span>basic_istream_view</span><span>views::istream</span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/repeat_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/repeat view (page does not exist)"><span class="t-lines"><span>repeat_view</span><span>views::repeat</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="../ranges.html#Range_adaptors" title="cpp/ranges">Adaptors</a></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="ref_view.html" title="cpp/ranges/ref view"><span class="t-lines"><span>ref_view</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="all_view.html" title="cpp/ranges/all view"><span class="t-lines"><span>views::all_t</span><span>views::all</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="common_view.html" title="cpp/ranges/common view"><span class="t-lines"><span>common_view</span><span>views::common</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="owning_view.html" title="cpp/ranges/owning view"><span class="t-lines"><span>owning_view</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="view_counted.html" title="cpp/ranges/view counted"><span class="t-lines"><span>views::counted</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="reverse_view.html" title="cpp/ranges/reverse view"><span class="t-lines"><span>reverse_view</span><span>views::reverse</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="zip_view.html" title="cpp/ranges/zip view"><span class="t-lines"><span>zip_view</span><span>views::zip</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><strong class="selflink"><span class="t-lines"><span>as_const_view</span><span>views::as_const</span></span></strong></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="as_rvalue_view.html" title="cpp/ranges/as rvalue view"><span class="t-lines"><span>as_rvalue_view</span><span>views::as_rvalue</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span><span><span class="t-mark-rev t-since-cxx23">(C++23)</span>  </span></span></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="take_view.html" title="cpp/ranges/take view"><span class="t-lines"><span>take_view</span><span>views::take</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="take_while_view.html" title="cpp/ranges/take while view"><span class="t-lines"><span>take_while_view</span><span>views::take_while</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="drop_view.html" title="cpp/ranges/drop view"><span class="t-lines"><span>drop_view</span><span>views::drop</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="drop_while_view.html" title="cpp/ranges/drop while view"><span class="t-lines"><span>drop_while_view</span><span>views::drop_while</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="zip_transform_view.html" title="cpp/ranges/zip transform view"><span class="t-lines"><span>zip_transform_view</span><span>views::zip_transform</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/adjacent_transform_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/adjacent transform view (page does not exist)"><span class="t-lines"><span>adjacent_transform_view</span><span>views::adjacent_transform</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span><span><span class="t-mark-rev t-since-cxx23">(C++23)</span>  </span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/cartesian_product_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/cartesian product view (page does not exist)"><span class="t-lines"><span>cartesian_product_view</span><span>views::cartesian_product</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="elements_view.html" title="cpp/ranges/elements view"><span class="t-lines"><span>elements_view</span><span>views::elements</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="keys_view.html" title="cpp/ranges/keys view"><span class="t-lines"><span>keys_view</span><span>views::keys</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="values_view.html" title="cpp/ranges/values view"><span class="t-lines"><span>values_view</span><span>views::values</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="transform_view.html" title="cpp/ranges/transform view"><span class="t-lines"><span>transform_view</span><span>views::transform</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/adjacent_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/adjacent view (page does not exist)"><span class="t-lines"><span>adjacent_view</span><span>views::adjacent</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/slide_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/slide view (page does not exist)"><span class="t-lines"><span>slide_view</span><span>views::slide</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/stride_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/stride view (page does not exist)"><span class="t-lines"><span>stride_view</span><span>views::stride</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"> <br>
</td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="filter_view.html" title="cpp/ranges/filter view"><span class="t-lines"><span>filter_view</span><span>views::filter</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="join_view.html" title="cpp/ranges/join view"><span class="t-lines"><span>join_view</span><span>views::join</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="split_view.html" title="cpp/ranges/split view"><span class="t-lines"><span>split_view</span><span>views::split</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="lazy_split_view.html" title="cpp/ranges/lazy split view"><span class="t-lines"><span>lazy_split_view</span><span>views::lazy_split</span></span></a></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="join_with_view.html" title="cpp/ranges/join with view"><span class="t-lines"><span>join_with_view</span><span>views::join_with</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/chunk_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/chunk view (page does not exist)"><span class="t-lines"><span>chunk_view</span><span>views::chunk</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div></td></tr>
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/chunk_by_view&amp;action=edit&amp;redlink=1" class="new" title="cpp/ranges/chunk by view (page does not exist)"><span class="t-lines"><span>chunk_by_view</span><span>views::chunk_by</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div></td></tr>
</table></div></td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="../ranges.html#Range_adaptor_objects" title="cpp/ranges">Range adaptor objects</a></td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="../ranges.html#Range_adaptor_closure_objects" title="cpp/ranges">Range adaptor closure objects</a></td></tr>
<tr class="t-nv-h2"><td colspan="5"> <a href="../ranges.html#Helper_concepts" title="cpp/ranges">Helper items</a></td></tr>
<tr class="t-nv-col-table"><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="copyable_wrapper.html" title="cpp/ranges/copyable wrapper"><span class="t-lines"><span><i>copyable-box</i></span></span></a></div></div></td></tr>
</table></div></td><td><div><table class="t-nv-begin" cellpadding="0" style="">
<tr class="t-nv"><td colspan="5"><div class="t-nv-ln-table"><div><a href="../ranges.html#Helper_concepts" title="cpp/ranges"><span class="t-lines"><span><i>simple-view</i></span></span></a></div></div></td></tr>
</table></div></td></tr>
</table></div><div></div></div></div></div><div class="t-navbar-sep"> </div></div>
<table class="t-dcl-begin"><tbody>
<tr class="t-dsc-header">
<td> <div>Defined in header <code><a href="../header/ranges.html" title="cpp/header/ranges">&lt;ranges&gt;</a></code>
 </div></td>
<td></td>
<td></td>
</tr>
<tr class="t-dcl t-since-cxx23">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw1">template</span><span class="sy1">&lt;</span> <a href="view.html"><span class="kw2904">ranges::<span class="me2">view</span></span></a> V <span class="sy1">&gt;</span><br>
<p>    requires <a href="input_range.html"><span class="kw2905">ranges::<span class="me2">input_range</span></span></a><span class="sy1">&lt;</span>V<span class="sy1">&gt;</span><br>
</p>
<span class="kw1">class</span> as_const_view <span class="sy4">:</span> <span class="kw1">public</span> <a href="view_interface.html"><span class="kw3106">ranges::<span class="me2">view_interface</span></span></a><span class="sy1">&lt;</span>as_const_view<span class="sy1">&lt;</span>V<span class="sy1">&gt;&gt;</span></span></div></td>
<td> (1) </td>
<td> <span class="t-mark-rev t-since-cxx23">(since C++23)</span> </td>
</tr>
<tr class="t-dcl t-since-cxx23">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw1">namespace</span> views <span class="br0">{</span><br>
<p>    <span class="kw1">inline</span> <span class="kw4">constexpr</span> <span class="coMULTI">/* unspecified */</span> as_const <span class="sy1">=</span> <span class="coMULTI">/* unspecified */</span><span class="sy4">;</span><br>
</p>
<span class="br0">}</span></span></div></td>
<td> (2) </td>
<td> <span class="t-mark-rev t-since-cxx23">(since C++23)</span> </td>
</tr>
<tr class="t-dcl-h">
<td> <div>Call signature</div></td>
<td></td>
<td></td>
</tr>
<tr class="t-dcl t-since-cxx23">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw1">template</span><span class="sy1">&lt;</span> <a href="viewable_range.html"><span class="kw2912">ranges::<span class="me2">viewable_range</span></span></a> R <span class="sy1">&gt;</span><br>
<p>    requires <span class="coMULTI">/* see below */</span><br>
</p>
<span class="kw4">constexpr</span> <a href="view.html"><span class="kw2904">ranges::<span class="me2">view</span></span></a> <span class="kw4">auto</span> as_const<span class="br0">(</span> R<span class="sy3">&amp;&amp;</span> r <span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td class="t-dcl-nopad">  </td>
<td> <span class="t-mark-rev t-since-cxx23">(since C++23)</span> </td>
</tr>
<tr class="t-dcl-sep"><td></td><td></td><td></td></tr>
</tbody></table>
<div class="t-li1"><span class="t-li">1)</span> A range adaptor that represents a view of underlying <a href="view.html" title="cpp/ranges/view"><code>view</code></a> that is also a <a href="constant_range.html" title="cpp/ranges/constant range"><code>constant_range</code></a>. An <code>as_const_view</code> always has read-only elements (if not empty).</div>
<div class="t-li1"><span class="t-li">2)</span> <a href="../ranges.html#Range_adaptor_objects" title="cpp/ranges">Range adaptor object</a>. Let <span class="t-c"><span class="mw-geshi cpp source-cpp">e</span></span> be a subexpression, let <span class="t-c"><span class="mw-geshi cpp source-cpp">T</span></span> be <span class="t-c"><span class="mw-geshi cpp source-cpp">decltype<span class="br0">(</span><span class="br0">(</span>e<span class="br0">)</span><span class="br0">)</span></span></span>, and let <span class="t-c"><span class="mw-geshi cpp source-cpp">U</span></span> be <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../types/remove_cvref.html"><span class="kw2647">std::<span class="me2">remove_cvref_t</span></span></a><span class="sy1">&lt;</span>T<span class="sy1">&gt;</span></span></span>. Then the expression <span class="t-c"><span class="mw-geshi cpp source-cpp">views<span class="sy4">::</span><span class="me2">as_const</span><span class="br0">(</span>e<span class="br0">)</span></span></span> is <i>expression-equivalent</i> to:
<ul><li> <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="all_view.html"><span class="kw2920">views::<span class="me2">all</span></span></a><span class="br0">(</span>e<span class="br0">)</span></span></span>, if it is a well-formed expression and <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="all_view.html"><span class="kw2919">views::<span class="me2">all_t</span></span></a><span class="sy1">&lt;</span>T<span class="sy1">&gt;</span></span></span> models <a href="constant_range.html" title="cpp/ranges/constant range"><code>constant_range</code></a>;
</li><li> otherwise, <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../container/span.html"><span class="kw2634">std::<span class="me2">span</span></span></a><span class="sy1">&lt;</span><span class="kw4">const</span> X, Extent<span class="sy1">&gt;</span><span class="br0">(</span>e<span class="br0">)</span></span></span> for some type <code>X</code> and some extent <code>Extent</code> if <code>U</code> denotes <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="../container/span.html"><span class="kw2634">std::<span class="me2">span</span></span></a><span class="sy1">&lt;</span>X, Extent<span class="sy1">&gt;</span></span></span>;
</li><li> otherwise, <span class="t-c"><span class="mw-geshi cpp source-cpp"><a href="ref_view.html"><span class="kw2921">ranges::<span class="me2">ref_view</span></span></a><span class="br0">(</span><span class="kw1">static_cast</span><span class="sy1">&lt;</span><span class="kw4">const</span> U<span class="sy3">&amp;</span><span class="sy1">&gt;</span><span class="br0">(</span>e<span class="br0">)</span><span class="br0">)</span></span></span> if <code>e</code> is an lvalue, <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw4">const</span> U</span></span> models <a href="constant_range.html" title="cpp/ranges/constant range"><code>constant_range</code></a>, and <span class="t-c"><span class="mw-geshi cpp source-cpp">U</span></span> does not model <a href="view.html" title="cpp/ranges/view"><code>view</code></a>.
</li><li> otherwise, <span class="t-c"><span class="mw-geshi cpp source-cpp">as_const_view<span class="br0">{</span>e<span class="br0">}</span></span></span>.</li></ul></div>

<p><code>as_const_view</code> always models <a href="constant_range.html" title="cpp/ranges/constant range"><code>constant_range</code></a>, and it models the <a href="contiguous_range.html" title="cpp/ranges/contiguous range"><code>contiguous_range</code></a>, <a href="random_access_range.html" title="cpp/ranges/random access range"><code>random_access_range</code></a>, <a href="bidirectional_range.html" title="cpp/ranges/bidirectional range"><code>bidirectional_range</code></a>, <a href="forward_range.html" title="cpp/ranges/forward range"><code>forward_range</code></a>, <a href="borrowed_range.html" title="cpp/ranges/borrowed range"><code>borrowed_range</code></a>, <a href="common_range.html" title="cpp/ranges/common range"><code>common_range</code></a>, and <a href="sized_range.html" title="cpp/ranges/sized range"><code>sized_range</code></a> when the underlying view <code>V</code> models respective concepts.
</p>
<h3><span class="mw-headline" id="Expression-equivalent">Expression-equivalent</span></h3>
<p>Expression <span class="t-c"><span class="mw-geshi cpp source-cpp">e</span></span> is <i>expression-equivalent</i> to expression <span class="t-c"><span class="mw-geshi cpp source-cpp">f</span></span>, if
</p>
<ul><li><span class="t-c"><span class="mw-geshi cpp source-cpp">e</span></span> and <span class="t-c"><span class="mw-geshi cpp source-cpp">f</span></span> have the same effects, and
</li><li>either both are <a href="../language/constant_expression.html" title="cpp/language/constant expression">constant subexpressions</a> or else neither is a constant subexpression, and
</li><li>either both are <a href="../language/noexcept_spec.html" title="cpp/language/noexcept spec">potentially-throwing</a> or else neither is potentially-throwing (i.e. <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw1">noexcept</span><span class="br0">(</span>e<span class="br0">)</span> <span class="sy1">==</span> <span class="kw1">noexcept</span><span class="br0">(</span>f<span class="br0">)</span></span></span>).
</li></ul>
<h3><span class="mw-headline" id="Data_members">Data members</span></h3>
<p>Typical implementations of <code>as_const_view</code> only hold one non-static data member: 
</p>
<ul><li> the underlying view of type <code>V</code> (shown here as <code><i>base_</i></code>, the name is exposition only).
</li></ul>
<h3><span class="mw-headline" id="Member_functions">Member functions</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div t-dsc-member-nobold-div"><div><span class="t-lines"><span>(constructor)</span></span></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div>
</td>
<td>  constructs an <code>as_const_view</code> <br> <span class="t-mark">(public member function)</span>
</td></tr>


<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>base</span></span></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div>
</td>
<td>   returns the underlying view <code>V</code>  <br> <span class="t-mark">(public member function)</span>
</td></tr>


<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>begin</span></span></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div>
</td>
<td>   returns the beginning iterator of the <code>as_const_view</code>  <br> <span class="t-mark">(public member function)</span>
</td></tr>


<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>end</span></span></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div>
</td>
<td>   returns the end iterator of the <code>as_const_view</code>  <br> <span class="t-mark">(public member function)</span>
</td></tr>


<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><span class="t-lines"><span>size</span></span></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx23">(C++23)</span></span></span></div></div>
</td>
<td>   returns the size of the view if it is bounded  <br> <span class="t-mark">(public member function)</span>
</td></tr>



<tr>
<td colspan="2"> <h5> <span class="mw-headline" id="Inherited_from_std::ranges::view_interface">  Inherited from <span class="t-lc"><a href="view_interface.html" title="cpp/ranges/view interface">std::ranges::view_interface</a></span>  </span></h5>
</td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="view_interface/empty.html" title="cpp/ranges/view interface/empty"> <span class="t-lines"><span>empty</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>   Returns whether the derived view is empty. Provided if it satisfies <a href="sized_range.html" title="cpp/ranges/sized range"><code>sized_range</code></a> or <a href="forward_range.html" title="cpp/ranges/forward range"><code>forward_range</code></a>.  <br> <span class="t-mark">(public member function of <code>std::ranges::view_interface&lt;D&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="view_interface/operator_bool.html" title="cpp/ranges/view interface/operator bool"> <span class="t-lines"><span>operator bool</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>   Returns whether the derived view is not empty. Provided if <span class="t-lc"><a href="empty.html" title="cpp/ranges/empty">ranges::empty</a></span> is applicable to it.  <br> <span class="t-mark">(public member function of <code>std::ranges::view_interface&lt;D&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="view_interface/data.html" title="cpp/ranges/view interface/data"> <span class="t-lines"><span>data</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>   Gets the address of derived view's data. Provided if its iterator type satisfies <a href="../iterator/contiguous_iterator.html" title="cpp/iterator/contiguous iterator"><code>contiguous_iterator</code></a>.  <br> <span class="t-mark">(public member function of <code>std::ranges::view_interface&lt;D&gt;</code>)</span> </td></tr>


<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="view_interface/front.html" title="cpp/ranges/view interface/front"> <span class="t-lines"><span>front</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>   Returns the first element in the derived view. Provided if it satisfies <a href="forward_range.html" title="cpp/ranges/forward range"><code>forward_range</code></a>. <br> <span class="t-mark">(public member function of <code>std::ranges::view_interface&lt;D&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="view_interface/back.html" title="cpp/ranges/view interface/back"> <span class="t-lines"><span>back</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>   Returns the last element in the derived view. Provided if it satisfies <a href="bidirectional_range.html" title="cpp/ranges/bidirectional range"><code>bidirectional_range</code></a> and <a href="common_range.html" title="cpp/ranges/common range"><code>common_range</code></a>.  <br> <span class="t-mark">(public member function of <code>std::ranges::view_interface&lt;D&gt;</code>)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="view_interface/operator_at.html" title="cpp/ranges/view interface/operator at"> <span class="t-lines"><span>operator[]</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>   Returns the nth element in the derived view. Provided if it satisfies <a href="random_access_range.html" title="cpp/ranges/random access range"><code>random_access_range</code></a>.  <br> <span class="t-mark">(public member function of <code>std::ranges::view_interface&lt;D&gt;</code>)</span> </td></tr>
</table>
<div class="t-member">
<h2> <span class="mw-headline" id="std::ranges::as_const_view::as_const_view"> <span style="font-size:0.7em; line-height:130%">std::ranges::as_const_view::</span>as_const_view </span></h2>
<table class="t-dcl-begin"><tbody>
<tr class="t-dcl t-since-cxx23">
<td> <div><span class="mw-geshi cpp source-cpp">as_const_view<span class="br0">(</span><span class="br0">)</span> requires <a href="../concepts/default_initializable.html"><span class="kw2950">std::<span class="me2">default_initializable</span></span></a><span class="sy1">&lt;</span>V<span class="sy1">&gt;</span> <span class="sy1">=</span> <span class="kw1">default</span><span class="sy4">;</span></span></div></td>
<td> (1) </td>
<td> <span class="t-mark-rev t-since-cxx23">(since C++23)</span> </td>
</tr>
<tr class="t-dcl t-since-cxx23">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">constexpr</span> <span class="kw1">explicit</span> as_const_view<span class="br0">(</span>V base<span class="br0">)</span><span class="sy4">;</span></span></div></td>
<td> (2) </td>
<td> <span class="t-mark-rev t-since-cxx23">(since C++23)</span> </td>
</tr>
<tr class="t-dcl-sep"><td></td><td></td><td></td></tr>
</tbody></table>
<div class="t-li1"><span class="t-li">1)</span> Value-initializes <code><i>base_</i></code> via its default member initializer (<span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="sy1">=</span> V<span class="br0">(</span><span class="br0">)</span></span></span>).</div>
<div class="t-li1"><span class="t-li">2)</span> Initializes <code><i>base_</i></code> with <span class="t-c"><span class="mw-geshi cpp source-cpp">std<span class="sy4">::</span><span class="me2">move</span><span class="br0">(</span>base<span class="br0">)</span></span></span>.</div>
<h3> <span class="mw-headline" id="Parameters">Parameters</span></h3>
<table class="t-par-begin">


<tr class="t-par">
<td>  base
</td>
<td> -
</td>
<td>  a view
</td></tr></table>
</div>
<div class="t-member">
<h2> <span class="mw-headline" id="std::ranges::as_const_view::base"> <span style="font-size:0.7em; line-height:130%">std::ranges::as_const_view::</span>base</span></h2>
<table class="t-dcl-begin"><tbody>
<tr class="t-dcl t-since-cxx23">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">constexpr</span> V base<span class="br0">(</span><span class="br0">)</span> <span class="kw4">const</span><span class="sy3">&amp;</span> requires <a href="../concepts/copy_constructible.html"><span class="kw2952">std::<span class="me2">copy_constructible</span></span></a><span class="sy1">&lt;</span>V<span class="sy1">&gt;</span><span class="sy4">;</span></span></div></td>
<td> (1) </td>
<td> <span class="t-mark-rev t-since-cxx23">(since C++23)</span> </td>
</tr>
<tr class="t-dcl t-since-cxx23">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">constexpr</span> V base<span class="br0">(</span><span class="br0">)</span> <span class="sy3">&amp;&amp;</span><span class="sy4">;</span></span></div></td>
<td> (2) </td>
<td> <span class="t-mark-rev t-since-cxx23">(since C++23)</span> </td>
</tr>
<tr class="t-dcl-sep"><td></td><td></td><td></td></tr>
</tbody></table>
<p>Returns the underlying view.
</p>
<div class="t-li1"><span class="t-li">1)</span> Copy-constructs the result from the underlying view. Equivalent to <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw1">return</span> base_<span class="sy4">;</span></span></span>.</div>
<div class="t-li1"><span class="t-li">2)</span> Move-constructs the result from the underlying view. Equivalent to <span class="t-c"><span class="mw-geshi cpp source-cpp"><span class="kw1">return</span> std<span class="sy4">::</span><span class="me2">move</span><span class="br0">(</span>base_<span class="br0">)</span><span class="sy4">;</span></span></span>.</div>
</div>
<div class="t-member">
<h2> <span class="mw-headline" id="std::ranges::as_const_view::begin"> <span style="font-size:0.7em; line-height:130%">std::ranges::as_const_view::</span>begin</span></h2>
<table class="t-dcl-begin"><tbody>
<tr class="t-dcl t-since-cxx23">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">constexpr</span> <span class="kw4">auto</span> begin<span class="br0">(</span><span class="br0">)</span> requires <span class="br0">(</span><span class="sy3">!</span><span class="coMULTI">/*simple-view*/</span><span class="sy1">&lt;</span>V<span class="sy1">&gt;</span><span class="br0">)</span> <span class="br0">{</span> <br>
<p>  <span class="kw1">return</span> <a href="../../../http:/en.cppreference.com/w/cpp/ranges-ranges-placeholder/cbegin"><span class="kw2886">ranges::<span class="me2">cbegin</span></span></a><span class="br0">(</span>base_<span class="br0">)</span><span class="sy4">;</span> <br>
</p>
<span class="br0">}</span></span></div></td>
<td> (1) </td>
<td> <span class="t-mark-rev t-since-cxx23">(since C++23)</span> </td>
</tr>
<tr class="t-dcl t-since-cxx23">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">constexpr</span> <span class="kw4">auto</span> begin<span class="br0">(</span><span class="br0">)</span> <span class="kw4">const</span> requires <a href="range.html"><span class="kw2901">ranges::<span class="me2">range</span></span></a><span class="sy1">&lt;</span><span class="kw4">const</span> V<span class="sy1">&gt;</span> <span class="br0">{</span> <br>
<p>  <span class="kw1">return</span> <a href="../../../http:/en.cppreference.com/w/cpp/ranges-ranges-placeholder/cbegin"><span class="kw2886">ranges::<span class="me2">cbegin</span></span></a><span class="br0">(</span>base_<span class="br0">)</span><span class="sy4">;</span> <br>
</p>
<span class="br0">}</span></span></div></td>
<td> (2) </td>
<td> <span class="t-mark-rev t-since-cxx23">(since C++23)</span> </td>
</tr>
<tr class="t-dcl-sep"><td></td><td></td><td></td></tr>
</tbody></table>
<p>Returns the constant iterator of the view.
</p>
</div>
<div class="t-member">
<h2> <span class="mw-headline" id="std::ranges::as_const_view::end"> <span style="font-size:0.7em; line-height:130%">std::ranges::as_const_view::</span>end</span></h2>
<table class="t-dcl-begin"><tbody>
<tr class="t-dcl t-since-cxx23">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">constexpr</span> <span class="kw4">auto</span> end<span class="br0">(</span><span class="br0">)</span> requires <span class="br0">(</span><span class="sy3">!</span><span class="coMULTI">/*simple-view*/</span><span class="sy1">&lt;</span>V<span class="sy1">&gt;</span><span class="br0">)</span> <span class="br0">{</span> <br>
<p>  <span class="kw1">return</span> <a href="../../../http:/en.cppreference.com/w/cpp/ranges-ranges-placeholder/cend"><span class="kw2888">ranges::<span class="me2">cend</span></span></a><span class="br0">(</span>base_<span class="br0">)</span><span class="sy4">;</span> <br>
</p>
<span class="br0">}</span></span></div></td>
<td> (1) </td>
<td> <span class="t-mark-rev t-since-cxx23">(since C++23)</span> </td>
</tr>
<tr class="t-dcl t-since-cxx23">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">constexpr</span> <span class="kw4">auto</span> end<span class="br0">(</span><span class="br0">)</span> <span class="kw4">const</span> requires <a href="range.html"><span class="kw2901">ranges::<span class="me2">range</span></span></a><span class="sy1">&lt;</span><span class="kw4">const</span> V<span class="sy1">&gt;</span> <span class="br0">{</span> <br>
<p>  <span class="kw1">return</span> <a href="../../../http:/en.cppreference.com/w/cpp/ranges-ranges-placeholder/cend"><span class="kw2888">ranges::<span class="me2">cend</span></span></a><span class="br0">(</span>base_<span class="br0">)</span><span class="sy4">;</span> <br>
</p>
<span class="br0">}</span></span></div></td>
<td> (2) </td>
<td> <span class="t-mark-rev t-since-cxx23">(since C++23)</span> </td>
</tr>
<tr class="t-dcl-sep"><td></td><td></td><td></td></tr>
</tbody></table>
<p>Returns the constant sentinel of the view.
</p>
</div>
<div class="t-member">
<h2> <span class="mw-headline" id="std::ranges::as_const_view::size"> <span style="font-size:0.7em; line-height:130%">std::ranges::as_const_view::</span>size</span></h2>
<table class="t-dcl-begin"><tbody>
<tr class="t-dcl t-since-cxx23">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">constexpr</span> <span class="kw4">auto</span> size<span class="br0">(</span><span class="br0">)</span> requires <a href="sized_range.html"><span class="kw2903">ranges::<span class="me2">sized_range</span></span></a><span class="sy1">&lt;</span>V<span class="sy1">&gt;</span> <span class="br0">{</span><br>
<p>    <span class="kw1">return</span> <a href="size.html"><span class="kw3103">ranges::<span class="me2">size</span></span></a><span class="br0">(</span>base_<span class="br0">)</span><span class="sy4">;</span><br>
</p>
<span class="br0">}</span></span></div></td>
<td> (1) </td>
<td> <span class="t-mark-rev t-since-cxx23">(since C++23)</span> </td>
</tr>
<tr class="t-dcl t-since-cxx23">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw4">constexpr</span> <span class="kw4">auto</span> size<span class="br0">(</span><span class="br0">)</span> <span class="kw4">const</span> requires <a href="sized_range.html"><span class="kw2903">ranges::<span class="me2">sized_range</span></span></a><span class="sy1">&lt;</span><span class="kw4">const</span> V<span class="sy1">&gt;</span> <span class="br0">{</span><br>
<p>    <span class="kw1">return</span> <a href="size.html"><span class="kw3103">ranges::<span class="me2">size</span></span></a><span class="br0">(</span>base_<span class="br0">)</span><span class="sy4">;</span><br>
</p>
<span class="br0">}</span></span></div></td>
<td> (2) </td>
<td> <span class="t-mark-rev t-since-cxx23">(since C++23)</span> </td>
</tr>
<tr class="t-dcl-sep"><td></td><td></td><td></td></tr>
</tbody></table>
<p>Returns the size of the view if the view is bounded.
</p>
</div>
<h3><span class="mw-headline" id="Deduction_guides">Deduction guides</span></h3>
<table class="t-dcl-begin"><tbody>

<tr class="t-dcl t-since-cxx23">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw1">template</span><span class="sy1">&lt;</span><span class="kw1">class</span> R<span class="sy1">&gt;</span><br>
as_const_view<span class="br0">(</span>R<span class="sy3">&amp;&amp;</span><span class="br0">)</span> <span class="sy2">-</span><span class="sy1">&gt;</span> as_const_view<span class="sy1">&lt;</span><a href="all_view.html"><span class="kw2919">views::<span class="me2">all_t</span></span></a><span class="sy1">&lt;</span>R<span class="sy1">&gt;&gt;</span><span class="sy4">;</span></span></div></td>
<td class="t-dcl-nopad">  </td>
<td> <span class="t-mark-rev t-since-cxx23">(since C++23)</span> </td>
</tr>
<tr class="t-dcl-sep"><td></td><td></td><td></td></tr>
</tbody></table>
<h3><span class="mw-headline" id="Helper_templates">Helper templates</span></h3>
<table class="t-dcl-begin"><tbody>

<tr class="t-dcl t-since-cxx23">
<td> <div><span class="mw-geshi cpp source-cpp"><span class="kw1">template</span><span class="sy1">&lt;</span><span class="kw1">class</span> T<span class="sy1">&gt;</span><br>
<p><span class="kw1">inline</span> <span class="kw4">constexpr</span> <span class="kw4">bool</span> enable_borrowed_range<span class="sy1">&lt;</span>std<span class="sy4">::</span><span class="me2">ranges</span><span class="sy4">::</span><span class="me2">as_const_view</span><span class="sy1">&lt;</span>T<span class="sy1">&gt;&gt;</span> <span class="sy1">=</span><br>
</p>
    std<span class="sy4">::</span><a href="borrowed_range.html"><span class="kw3276">ranges::<span class="me2">enable_borrowed_range</span></span></a><span class="sy1">&lt;</span>T<span class="sy1">&gt;</span><span class="sy4">;</span></span></div></td>
<td class="t-dcl-nopad">  </td>
<td> <span class="t-mark-rev t-since-cxx23">(since C++23)</span> </td>
</tr>
<tr class="t-dcl-sep"><td></td><td></td><td></td></tr>
</tbody></table>
<p>This specialization of <a href="borrowed_range.html" title="cpp/ranges/borrowed range"><tt>std::ranges::enable_borrowed_range</tt></a> makes <code>as_const_view</code> satisfy <a href="borrowed_range.html" title="cpp/ranges/borrowed range"><code>borrowed_range</code></a> when the underlying view satisfies it.
</p>
<h3><span class="mw-headline" id="Example">Example</span></h3>
<table class="metadata plainlinks ambox mbox-small-left ambox-notice" style=""><tr><td class="mbox-empty-cell"></td><td class="mbox-text" style="">This section is incomplete<br>Reason: example </td></tr></table>
<h3><span class="mw-headline" id="See_also">See also</span></h3>
<table class="t-dsc-begin">

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="cbegin.html" title="cpp/ranges/cbegin"> <span class="t-lines"><span>ranges::cbegin</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  returns an iterator to the beginning of a read-only range  <br> <span class="t-mark">(customization point object)</span> </td></tr>

<tr class="t-dsc">
<td>  <div class="t-dsc-member-div"><div><a href="cend.html" title="cpp/ranges/cend"> <span class="t-lines"><span>ranges::cend</span></span></a></div><div><span class="t-lines"><span><span class="t-mark-rev t-since-cxx20">(C++20)</span></span></span></div></div>
</td>
<td>  returns a sentinel indicating the end of a read-only range  <br> <span class="t-mark">(customization point object)</span> </td></tr>
</table>

<!-- 
NewPP limit report
Preprocessor visited node count: 13219/1000000
Preprocessor generated node count: 16161/1000000
Post‐expand include size: 289438/2097152 bytes
Template argument size: 59475/2097152 bytes
Highest expansion depth: 41/40
Expensive parser function count: 0/100
-->

<!-- Saved in parser cache with key mwiki1-mwiki_en_:pcache:idhash:21030-0!*!0!!en!*!* and timestamp 20220730104952 -->
</div>                    <!-- /bodycontent -->
                                        <!-- printfooter -->
                    <div class="printfooter">
                    Retrieved from "<a href="https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/as_const_view&amp;oldid=141609">https://en.cppreference.com/mwiki/index.php?title=cpp/ranges/as_const_view&amp;oldid=141609</a>"                    </div>
                    <!-- /printfooter -->
                                                            <!-- catlinks -->
                    <!-- /catlinks -->
                                                            <div class="visualClear"></div>
                    <!-- debughtml -->
                                        <!-- /debughtml -->
                </div>
                <!-- /bodyContent -->
            </div>
        </div>
        <!-- /content -->
        <!-- footer -->
        <div id="cpp-footer-base" class="noprint">
            <div id="footer">
                        <div id="cpp-navigation">
            <h5>Navigation</h5>
            <ul><li><a href="https://en.cppreference.com/w/cpp/ranges/as_const_view">Online version</a></li><li>Offline version retrieved 2022-07-30 14:05.</li></ul></div>
                        <ul id="footer-info">
                                    <li id="footer-info-lastmod"> This page was last modified on 30 July 2022, at 03:43.</li>
                                    <li id="footer-info-viewcount">This page has been accessed once.</li>
                            </ul>
                    </div>
        </div>
        <!-- /footer -->
        <script>if(window.mw){
mw.loader.state({"site":"loading","user":"missing","user.groups":"ready"});
}</script>
<script src="../../../common/skin_scripts.js"></script>
<script>if(window.mw){
mw.loader.load(["mediawiki.action.view.postEdit","mediawiki.user","mediawiki.page.ready","mediawiki.searchSuggest","mediawiki.hidpi","ext.gadget.ColiruCompiler","ext.gadget.MathJax"], null, true);
}</script>
<script src="../../../common/site_scripts.js"></script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-2828341-1']);
_gaq.push(['_setDomainName', 'cppreference.com']);
_gaq.push(['_trackPageview']);
</script><!-- Served in 3.142 secs. -->
	</body>
<!-- Cached 20220730104952 -->
</html>